import { http } from '@/utils/request'
import type { SysPostListParamsType, SysPostListType } from './model'

/**
 * 获取岗位列表
 * @returns SysPostListType[]
 */
export const getPostListAPI = (params: SysPostListParamsType) => {
  return http.request<PageResult<SysPostListType>>('get', '/sys_post', {
    params
  })
}

/**
 * 获取岗位详情
 * @param id 岗位ID
 * @returns SysPostListType
 */
export const getPostDetailAPI = (id: number) => {
  return http.request<SysPostListType>('get', `/sys_post/${id}`)
}

/**
 * 新增岗位
 * @param data 岗位数据
 * @returns
 */
export const addPostAPI = (data: SysPostListType) => {
  return http.request('post', '/sys_post', { data })
}

/**
 * 更新岗位
 * @param id 岗位ID
 * @param data 岗位数据
 * @returns
 */
export const updatePostAPI = (id: number, data: SysPostListType) => {
  return http.request('put', `/sys_post/${id}`, { data })
}

/**
 * 删除岗位
 * @param id 岗位ID
 * @returns
 */
export const deletePostAPI = (id: number) => {
  return http.request('delete', `/sys_post/${id}`)
}
